/**
 * 
 */
package com.l.brownapp.utils;

import android.app.Activity;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnKeyListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.PopupWindow;

import com.l.brownapp.R;

/**
 * @author Administrator
 * 
 */
public final class CustomMenu {

	private static final String TAG = "CustomMenu";
	private static PopupWindow pop = null;

	public static PopupWindow getMenu(Activity activity,
			OnClickListener listener, OnTouchListener touchListener,
			OnKeyListener keyListener) {
		View view = activity.getLayoutInflater()
				.inflate(R.layout.my_menu, null);
		pop = new PopupWindow(view, ViewGroup.LayoutParams.FILL_PARENT,
				ViewGroup.LayoutParams.WRAP_CONTENT);

		pop.setAnimationStyle(R.style.pop_anim_style);
		pop.setBackgroundDrawable(activity.getResources().getDrawable(
				R.drawable.pop_menu_bg));
		pop.setFocusable(true);
		pop.setTouchable(true);
		pop.setOutsideTouchable(true);
		view.setFocusableInTouchMode(true);
		pop.setTouchInterceptor(touchListener);
		view.setOnKeyListener(keyListener);

		Log.i(TAG, pop.toString());
		Button menu_button_clear=(Button) view.findViewById(R.id.menu_button_clear);
		menu_button_clear.setOnClickListener(listener);
		Button menu_button_test2=(Button) view.findViewById(R.id.menu_button_test2);
		menu_button_test2.setOnClickListener(listener);
		Button menu_button_cancel=(Button) view.findViewById(R.id.menu_button_cancel);
		menu_button_cancel.setOnClickListener(listener);
		
		Log.i(TAG, pop.toString());
		return pop;
	}
}
